{include file="common/_meta" /}
<title></title>
</head>

<body>
	<nav class="breadcrumb">
		<i class="Hui-iconfont">&#xe67f;</i> 首页
		<span class="c-gray en">&gt;</span>会员管理
		<span class="c-gray en">&gt;</span> 会员列表
		<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);"
		 title="刷新">
			<i class="Hui-iconfont">&#xe68f;</i>
		</a>
	</nav>
	<div class="page-container">
		<div class="cl pd-5 bg-1 bk-gray mt-20">
			<a class="btn btn-primary radius" onclick="userAdd(1)" href="javascript:;">
				<i class="Hui-iconfont"></i> 添加会员</a>
			<span class="r">共有数据：
				<strong>{$list->total()}</strong> 条</span>
		</div>
		<div class="mt-20">
			<table class="table table-border  table-hover table-bg table-sort">
				<thead>
					<tr class="text-c">
						<th width="25">
							<input type="checkbox" name="" value="">
						</th>
						<th>编号</th>
						<th>姓名 <span style="color:#ff9966">|</span> 电话</th>
						<th>等级</th>
						<th>QQ号码</th>
						<th>总资产</th>
						<th>推荐人</th>
						<th>会员状态</th>
						<th>在线状态</th>
						<th>完善状态</th>
						<th>信息查看</th>
						<th>注册时间</th>
						<th width="10%">操&nbsp;&nbsp;&nbsp;&nbsp;作</th>
					</tr>
				</thead>
				<tbody>
					{volist name='list' id="vo"}
					<tr class="text-c">
						<td>
							<input type="checkbox" value="1" name="">
						</td>
						<td>{$i}</td>
						<td>{$vo.username}<span style="color:#ff9966">|</span>{$vo.mobile}</td>
						<td>
							{if(count($group))}
								{$group[$vo.group_id]}
							{/if}
						</td>
						<td>
							{$vo.QQaccount}
						</td>
						<td>
							{$vo.total_funds}
						</td>
						<td>
							<a href="{$vo.userParent.username? '' : '#'}">
								{$vo.userParent.username}
							</a>
						</td>
						<td class="td-status">
							{if condition="$vo.status eq 1"}
							<span class="label label-success radius">已启用</span>
							{else/}
							<span class="label label-error radius">已冻结</span>
							{/if}
						</td>
						<td class="td-online">
							{if condition="$vo.online eq 1"}
							<span class="label label-success radius">在线</span>
							{else/}
							<span class="label label-error radius">离线</span>
							{/if}
						</td>
						<td class="td-perfect">
							{if condition="$vo.perfect eq 1"}
							<span class="label label-success radius">完善</span>
							{else/}
							<span class="label label-error radius">不完善</span>
							{/if}
						</td>
						<td>
							{$vo.sign_time}
						</td>
						<td>
							<a href="javascript:;" onclick='showuser({$vo})'>会员详情</a> <span style="color:#ff9966">|</span>
							<a href="javascript:;" onclick='showfunds({$vo})'>账户详情</a>
							<!--  <span style="color:#ff9966">|</span> 
							<a href="{:url('userAcclog')}?page=1&id={$vo.id}">交易记录</a> -->
						</td>
						<td class="td-manage">
							{if condition="$vo.status eq 1"}
							<a style="text-decoration:none" onClick="us_stop(this,{$vo.id})" href="javascript:;" title="冻结">
								<i class="Hui-iconfont">&#xe631;</i>
							</a>
							{else/}
							<a style="text-decoration:none" onClick="us_start(this,{$vo.id})" href="javascript:;" title="激活">
								<i class="Hui-iconfont">&#xe6a7;</i>
							</a>
							{/if} &nbsp;&nbsp;
							<a style="text-decoration:none" class="ml-5" onClick="resetpwd(this,{$vo.id})" href="javascript:;" title="重置密码">
								<i class="Hui-iconfont">&#xe63f;</i>
							</a>
							 &nbsp;&nbsp;
							<a style="text-decoration:none" href="javascript:;" onClick="editInfo(this, {$vo.id})" title="编辑">
								<i class="Hui-iconfont">&#xe6df;</i>
							</a>
							 &nbsp;&nbsp;
							<a style="text-decoration:none" href="javascript:;" onClick="todel(this, {$vo.id})" title="删除">
								<i class="Hui-iconfont">&#xe6a6;</i>
							</a>
						</td>
					</tr>
					{/volist}
				</tbody>
			</table>
			<div class="pages" style="margin:20px;float: right; ">{$list->render()}</div>
		</div>
		<!-- 修改会员 -->
		<div id="user_edit" class="modal fade" style="margin: 0 auto;" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
		 aria-hidden="true">
			<div class="modal-dialog">
				<div class="modal-content radius">
					<div class="modal-header">
						<h3 class="modal-title"></h3>
						<a class="close" data-dismiss="modal" aria-hidden="true" href="javascript:void();">×</a>
					</div>
					<div class="modal-body">
						<article class="page-container" style="padding-right: 10%;">
							<form action="" method="post" class="form form-horizontal" id="form-user-edit">
								<div class="row cl hidden">
									<label class="form-label col-xs-4 col-sm-3"></label>
									<div class="formControls col-xs-8 col-sm-9">
										<input type="text" name="id" id="id" class="input-text" placeholder="" autocomplete="off" value="0">
									</div>
								</div>
								<div class="row cl">
									<label class="form-label col-xs-4 col-sm-3">会员姓名：</label>
									<div class="formControls col-xs-8 col-sm-9">
										<input type="text" name="username" id="name" class="input-text" autocomplete="off" disabled="true">
									</div>
								</div>
								<div class="row cl">
									<label class="form-label col-xs-4 col-sm-3">推荐人手机号：</label>
									<div class="formControls col-xs-8 col-sm-9">
										<input type="text" name="pmobile" id="p_tel" class="input-text" autocomplete="off" placeholder="手机号">
									</div>
								</div>
								<div class="row cl">
									<label class="form-label col-xs-4 col-sm-3">手机号：</label>
									<div class="formControls col-xs-8 col-sm-9">
										<input type="text" name="mobile" id="tel" class="input-text" autocomplete="off">
									</div>
								</div>
								<div class="row cl">
									<label class="form-label col-xs-4 col-sm-3">会员等级：</label>
									<div class="formControls col-xs-8 col-sm-9">
										<select name="group_id" id="group" class="input-text" autocomplete="off">
											{volist name="group" id="vo" key = "k"}
												<option value="{$k}">{$vo}</option>
											{/volist}
										</select>
									</div>
								</div>
								<div class="row cl">
									<label class="form-label col-xs-4 col-sm-3">QQ号码：</label>
									<div class="formControls col-xs-8 col-sm-9">
										<input type="text" name="QQaccount" id="QQaccount" class="input-text" autocomplete="off">
									</div>
								</div>
								<div class="row cl">
									<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
										<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
										<input class="btn btn-primary radius hidden" type="reset" value="&nbsp;&nbsp;重置&nbsp;&nbsp;" id="reset">
									</div>
								</div>
							</form>
						</article>
					</div>
				</div>
			</div>
		</div>
		<!-- 添加会员 -->
		<div id="user_add" class="modal fade" style="margin: 0 auto;" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
		 aria-hidden="true">
			<div class="modal-dialog">
				<div class="modal-content radius">
					<div class="modal-header">
						<h3 class="modal-title"></h3>
						<a class="close" data-dismiss="modal" aria-hidden="true" href="javascript:void();">×</a>
					</div>
					<div class="modal-body">
						<article class="page-container" style="padding-right: 10%;">
							<form action="" method="post" class="form form-horizontal" id="form-user-add">
								<div class="row cl">
									<label class="form-label col-xs-4 col-sm-3">会员姓名：</label>
									<div class="formControls col-xs-8 col-sm-9">
										<input type="text" name="username" id="p_id" class="input-text" autocomplete="off">
									</div>
								</div>
								<div class="row cl">
									<label class="form-label col-xs-4 col-sm-3">手机号：</label>
									<div class="formControls col-xs-8 col-sm-9">
										<input type="text" name="mobile" class="input-text" autocomplete="off">
									</div>
								</div>
								<div class="row cl">
									<label class="form-label col-xs-4 col-sm-3">登录密码：</label>
									<div class="formControls col-xs-8 col-sm-9">
										<input type="text" name="password" class="input-text" autocomplete="off">
									</div>
								</div>
								<div class="row cl">
									<label class="form-label col-xs-4 col-sm-3">会员等级：</label>
									<div class="formControls col-xs-8 col-sm-9">
										<!-- <input type="text" name="bank" class="input-text" autocomplete="off"> -->
										<select class="input-text" name="group_id" autocomplete="off">
												{volist name="group" id="vo" key = "k"}
												<option value="{$k}">{$vo}</option>
												{/volist}
										</select>
									</div>
								</div>
								<div class="row cl">
									<label class="form-label col-xs-4 col-sm-3">推荐人电话：</label>
									<div class="formControls col-xs-8 col-sm-9">
										<input type="text" name="pmobile" class="input-text" autocomplete="off">
									</div>
								</div>

								<div class="row cl">
									<label class="form-label col-xs-4 col-sm-3">QQ号码：</label>
									<div class="formControls col-xs-8 col-sm-9">
										<input type="text" name="QQaccount" class="input-text" autocomplete="off">
									</div>
								</div>
								<div class="row cl">
									<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
										<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
									</div>
								</div>
							</form>
						</article>
					</div>
				</div>
			</div>
		</div>
		<!-- 用户详情 -->
		<div id="user_details" class="modal fade" style="margin: 0 auto;" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
		 aria-hidden="true">
			<div class="modal-dialog">
				<div class="modal-content radius">
					<div class="modal-header">
						<h3 class="modal-title"></h3>
						<a class="close" data-dismiss="modal" aria-hidden="true" href="javascript:void();">×</a>
					</div>
					<div class="modal-body">
						<article class="page-container" style="padding-right: 10%;">
							<form action="" method="post" class="form form-horizontal" id="form-user-edbasic">
								<div class="row cl">
									<label class="form-label col-xs-4 col-sm-3">手机号：</label>
									<div class="formControls col-xs-8 col-sm-9">
										<input type="hidden" name="id" value="">
										<input type="tel" name="mobile" class="input-text" autocomplete="off" disabled="true">
									</div>
								</div>
								<div class="row cl">
									<label class="form-label col-xs-4 col-sm-3">姓名：</label>
									<div class="formControls col-xs-8 col-sm-9">
										<input type="text" name="username" class="input-text" autocomplete="off">
									</div>
								</div>
								<div class="row cl">
									<label class="form-label col-xs-4 col-sm-3">身份证号：</label>
									<div class="formControls col-xs-8 col-sm-9">
										<input type="text" name="ID_card_number" class="input-text" autocomplete="off">
									</div>
								</div>
								<div class="row cl">
									<label class="form-label col-xs-4 col-sm-3">开户银行：</label>
									<div class="formControls col-xs-8 col-sm-9">
										<input type="text" name="bank_name" class="input-text" autocomplete="off">
									</div>
								</div>

								<div class="row cl">
									<label class="form-label col-xs-4 col-sm-3">银行卡号：</label>
									<div class="formControls col-xs-8 col-sm-9">
										<input type="text" name="bank_num" class="input-text" autocomplete="off">
									</div>
								</div>
								<div class="row cl">
									<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
										<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
									</div>
								</div>
							</form>
						</article>
					</div>
				</div>
			</div>
		</div>
		<!-- 用户用户资金 -->
		<div id="user_funds" class="modal fade" style="margin: 0 auto;" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
		 aria-hidden="true">
			<div class="modal-dialog">
				<div class="modal-content radius">
					<div class="modal-header">
						<h3 class="modal-title"></h3>
						<a class="close" data-dismiss="modal" aria-hidden="true" href="javascript:void();">×</a>
					</div>
					<div class="modal-body">
						<article class="page-container" style="padding-right: 10%;">
							<form action="" method="post" class="form form-horizontal" id="form-user-funds">
								<div class="row cl">
									<label class="form-label col-xs-4 col-sm-3">手机号：</label>
									<div class="formControls col-xs-8 col-sm-9">
										<input type="hidden" name="id" value="">
										<input type="tel" name="mobile" class="input-text" autocomplete="off" disabled="true">
									</div>
								</div>
								<div class="row cl">
									<label class="form-label col-xs-4 col-sm-3">总资金：</label>
									<div class="formControls col-xs-8 col-sm-9">
										<input type="text" name="total_funds" class="input-text" autocomplete="off" disabled="true">
									</div>
								</div>
								<div class="row cl">
									<label class="form-label col-xs-4 col-sm-3">账户余额：</label>
									<div class="formControls col-xs-8 col-sm-9">
										<input type="text" name="available_funds" class="input-text" autocomplete="off">
									</div>
								</div>
								<div class="row cl">
									<label class="form-label col-xs-4 col-sm-3">投资金额：</label>
									<div class="formControls col-xs-8 col-sm-9">
										<input type="text" name="settlemen_funds" class="input-text" autocomplete="off">
									</div>
								</div>

								<div class="row cl">
									<label class="form-label col-xs-4 col-sm-3">佣金：</label>
									<div class="formControls col-xs-8 col-sm-9">
										<input type="text" name="commission" class="input-text" autocomplete="off">
									</div>
								</div>
								<div class="row cl">
									<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
										<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
									</div>
								</div>
							</form>
						</article>
					</div>
				</div>
			</div>
		</div>

	</div>
	{include file="common/_footer" /}
	<!--请在下方写此页面业务相关的脚本-->
	<script type="text/javascript">
	 	// 冻结用户
		function us_stop(obj, id) {
			layer.confirm('确认要冻结该用户吗？', function (index) {
				$.ajax({
					type: 'POST',
					url: "{:url('Nsuser/index')}?act=status",
					data: { 'id': id },
					dataType: 'json',
					success: function (data) {
						if (data.code) {
							$(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" onClick="us_start(this,' + id + ')" href="javascript:;" title="启用"><i class="Hui-iconfont">&#xe6e1;</i></a>');
							$(obj).parents("tr").find(".td-status").html('<span class="label label-defaunt radius">已冻结</span>');
							$(obj).remove();
						}
						layer.msg(data.msg, { icon: 6, time: 1000 });
					},
					error: function (data) {
						console.log(data.msg);
					},
				});
			});
		}

		// 启用用户
		function us_start(obj, id) {
			layer.confirm('确认要启用该用户吗？', function (index) {
				$.ajax({
					type: 'POST',
					url: "{:url('Nsuser/index')}?act=status",
					data: { 'id': id },
					dataType: 'json',
					success: function (data) {
						if (data.code) {
							$(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" onClick="us_stop(this,' + id + ')" href="javascript:;" title="冻结"><i class="Hui-iconfont">&#xe631;</i></a>');
							$(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">已启用</span>');
							$(obj).remove();
						}
						layer.msg(data.msg, { icon: 6, time: 1000 });
					},
					error: function (data) {
						console.log(data.msg);
					},
				});
			});
		}

		// 重置密码
		function resetpwd(obj, id) {
			layer.confirm('确认要重置吗？', function (index) {
				$.ajax({
					type: 'POST',
					url: "{:url('Nsuser/index')}?act=reset",
					data: { 'id': id },
					dataType: 'json',
					success: function (data) {
						layer.msg('密码:123456,已重置!', { icon: 1, time: 1000 });
					},
					error: function (data) {
						console.log(data.msg);
					},
				});
			});
		}

		// 软删除
		function todel(obj, id) {
			layer.confirm('确认要重置吗？', function (index) {
				$.ajax({
					type: 'POST',
					url: "{:url('Nsuser/index')}?act=todel",
					data: { 'id': id },
					dataType: 'json',
					success: function (data) {
						layer.msg(data.msg);
						if (data.code) {
							setTimeout(function () {
								history.go(0);
							}, 1000);
						}
					}
				});
			});
		}

		// function add(obj, id, type, title) {
		// 	var o_num = parseFloat($(obj).text());
		// 	layer.prompt({ title: title, }, function (num) {
		// 		if (num) {
		// 			$.post("{:url('User/index')}?act=acc", { id: id, num: num, type: type }).success(function (data) {
		// 				layer.msg(data.msg);
		// 				if (data.code) {
		// 					$(obj).text(o_num + parseFloat(num));
		// 				}
		// 			})
		// 		}
		// 	});
		// }
		// 

		// 添加会员展示
		function userAdd() {
			$("#user_add").modal("show");
		}

		// 执行添加用户
		$("#form-user-add").find('input:submit').click(function () {
			$.post("{:url('Nsuser/index')}?act=add", $("#form-user-add").serialize()).success(function (data) {
				layer.msg(data.msg);
				if (data.code) {
					setTimeout(function () {
						history.go(0);
					}, 1000);
				}
			});
			return false;
		});

		// 修改用户信息展示
		function editInfo(obj, id) {
			$.post("{:url('Nsuser/index')}?act=get", { id: id }, function(data){
				if (data) {
					$('#id').val(id);
					$('#name').val(data.username);
					$('#tel').val(data.mobile);
					if(null == data.user_parent) {
						if(data.id == 1){
							$('#p_tel').attr('disabled',true);
						}
						$('#p_tel').val('');
					}else{
						$('#p_tel').attr('disabled',false);
						$('#p_tel').val(data.user_parent.mobile);
					}
					$('#QQaccount').val(data.QQaccount);
					$("#group").children("option[value='"+data.group_id+"']").attr("selected",true);

					$("#user_edit").modal("show");
				}
			});
		}

		// 执行用户基本信息修改
		$("#form-user-edit").find('input:submit').click(function () {
			$.post("{:url('Nsuser/index')}?act=edbase", $("#form-user-edit").serialize()).success(function (data) {
				layer.msg(data.msg);
				if (data.code) {
					setTimeout(function () {
						history.go(0);
					}, 1000);
				}
			});
			return false;
		});

		// 执行用户详情修改
		$("#form-user-edbasic").find('input:submit').click(function () {
			$.post("{:url('Nsuser/index')}?act=edbasic", $("#form-user-edbasic").serialize()).success(function (data) {
				layer.msg(data.msg);
				if (data.code) {
					setTimeout(function () {
						history.go(0);
					}, 1000);
				}
			});
			return false;
		});

		// 执行用户资金修改
		$("#form-user-funds").find('input:submit').click(function () {
			$.post("{:url('Nsuser/index')}?act=funds", $("#form-user-funds").serialize()).success(function (data) {
				layer.msg(data.msg);
				if (data.code) {
					setTimeout(function () {
						history.go(0);
					}, 1000);
				}
			});
			return false;
		});

		// 显示会员详情
		function showuser (data) {
			$("#user_details input[type!=submit]").val('');
			$('#user_details').modal('show');
			$("#user_details input[name=id]").val(data.id);
			$("#user_details input[name=mobile]").val(data.mobile);
			$("#user_details input[name=username]").val(data.username);
			$("#user_details input[name=ID_card_number]").val(data.ID_card_number);
			$("#user_details input[name=bank_name]").val(data.bank_name);
			$("#user_details input[name=bank_num]").val(data.bank_num);
		}

		// 显示资金详情
		function showfunds (data) {
			$("#user_funds input[type!=submit]").val('');
			$('#user_funds').modal('show');
			$("#user_funds input[name=id]").val(data.id);
			$("#user_funds input[name=mobile]").val(data.mobile);
			$("#user_funds input[name=total_funds]").val(data.total_funds);
			$("#user_funds input[name=available_funds]").val(data.available_funds);
			$("#user_funds input[name=settlemen_funds]").val(data.settlemen_funds);
			$("#user_funds input[name=commission]").val(data.commission);
		}

		// 系统搜索
		$(function(){
		  $('.table-sort').dataTable({
		    "aaSorting": [[ 0, "desc" ]],//默认第几个排序
		    "bStateSave": true,//状态保存
		    "aoColumnDefs": [
		      //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
		      {"orderable":false,"aTargets":[0,2,4]}// 制定列不参与排序
		    ]
		  });
		});		

	</script>
</body>

</html>